<?php
namespace Common\Model;
use Think\Model;
class CustomizedGuiderModel extends Model {

    /**
     * model的中文名称
     */
    public $modelName = '定制导游订单';

    /**
     * model的icon
     */
    public $modelIcon = 'icon-bars';
    
    protected $_auto = [
        ["start_time", "strtotime", 3, "function"],
        ["end_time", "strtotime", 3, "function"],
        ["create_time", "time", 1, "function"],
        ["update_time", "time", 2, "function"],
    ];
    protected $_validate = [
        ["id", "require", "ID必须填写!"],
        ["user_id", "require", "购买用户必须填写!"],
        ["guider_user_id", "require", "导游必须填写!"],
        ["name", "require", "订单名称必须填写!"],
        ["start_time", "lateToNow", "开始日期必须晚于当前时间!", 1, 'callback', 3],
        ["start_time,end_time", "lateToEndTime", "开始日期必须早于结束时间!", 1, 'callback', 3],
        ["start_time", "require", "开始日期必须填写!"],
        ["end_time", "require", "结束日期必须填写!"],
        ["price", "require", "价格必须填写!"],
        ["user_name", "require", "用户姓名必须填写!"],
        ["user_phone", "require", "用户电话必须填写!"],
        ["user_gender", "require", "用户性别必须填写!"],
        ["user_contract", "require", "用户补充合同必须填写!"],
        ["guider_contract", "require", "导游补充合同必须填写!"],
        ["create_time", "require", "创建时间必须填写!"],
        ["update_time", "require", "更新时间必须填写!"],

    ];

    public function lateToNow($start_time) {
        if(strtotime($start_time) < strtotime(date('Y-m-d'))) {
            return false;
        }
    }
    public function lateToEndTime($data) {
        //继续传入参数问题
        if ($data['start_time'] > $data['end_time']) {
            return false;
        } else {
            return true;
        }
    }
    
    public $excel = false;

    public $fieldMap = [
        "id"=>[
            "type"=>"input",
            "name"=>"ID",
            "list"=>true,
            "search"=>true,
            "input"=>false,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
        ],
        "user_id"=>[
            "type"=>"foreign",
            "name"=>"购买用户",
            "list"=>true,
            "search"=>true,
            "input"=>true,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"user,id,name,input",
            "list_specify"=>"",
        ],
        "guider_user_id"=>[
            "type"=>"foreign",
            "name"=>"导游",
            "list"=>true,
            "search"=>true,
            "input"=>true,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"user,id,name,input",
            "list_specify"=>"",
        ],
        "name"=>[
            "type"=>"input",
            "name"=>"订单名称",
            "list"=>true,
            "search"=>true,
            "input"=>true,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
        ],
        "start_time"=>[
            "type"=>"date",
            "name"=>"开始日期",
            "list"=>true,
            "search"=>false,
            "input"=>true,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
        ],
        "end_time"=>[
            "type"=>"date",
            "name"=>"结束日期",
            "list"=>true,
            "search"=>false,
            "input"=>true,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
        ],
        "price"=>[
            "type"=>"input",
            "name"=>"价格",
            "list"=>true,
            "search"=>false,
            "input"=>true,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
        ],
        "amount"=>[
            "type"=>"input",
            "name"=>"总价",
            "list"=>true,
            "search"=>false,
            "input"=>true,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
        ],
        "content"=>[
            "type"=>"ueditor",
            "name"=>"行程详情",
            "list"=>false,
            "search"=>false,
            "input"=>true,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
        ],
        "user_name"=>[
            "type"=>"input",
            "name"=>"用户姓名",
            "list"=>true,
            "search"=>false,
            "input"=>true,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
        ],
        "user_phone"=>[
            "type"=>"input",
            "name"=>"用户电话",
            "list"=>true,
            "search"=>false,
            "input"=>true,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
        ],
        "user_gender"=>[
            "type"=>"input",
            "name"=>"用户性别",
            "list"=>true,
            "search"=>false,
            "input"=>true,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
        ],
        "user_contract"=>[
            "type"=>"ueditor",
            "name"=>"用户补充合同",
            "list"=>false,
            "search"=>false,
            "input"=>true,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
        ],
        "guider_contract"=>[
            "type"=>"ueditor",
            "name"=>"导游补充合同",
            "list"=>false,
            "search"=>false,
            "input"=>true,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
        ],
        "state" => [
            "type" => "input",
            "name" => "订单状态",
            "show" => true,
            "search" => false,
            "input" => false,
            "required" => true,
            "detail" => true,
            "excel" => true,
            "content" => "",
            "list_specify" => "",
        ],
        "create_time"=>[
            "type"=>"datetime",
            "name"=>"创建时间",
            "list"=>false,
            "search"=>false,
            "input"=>false,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
        ],
        "update_time"=>[
            "type"=>"datetime",
            "name"=>"更新时间",
            "list"=>false,
            "search"=>false,
            "input"=>false,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
        ],
        "insurance"=>[
            "type"=>"input",
            "name"=>"保险",
            "list"=>true,
            "search"=>false,
            "input"=>false,
            "required"=>false,
            "detail"=>false,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>'<td class="center"><a href="__MODULE__/InsuranceOrder/list?searchMap[order_type]=customized_guider&searchMap[order_id]={$vo[\'id\']}">点击查看</a></td>',
            "update_specify"=>"",
            "detail_specify"=>"",
        ],
    ];
}
